//
//  FirstTitleDetailTravelTableViewCell.m
//  BTRIP
//
//  Created by dllo on 15/11/14.
//  Copyright © 2015年 johnbk. All rights reserved.
//

#import "FirstTitleDetailTravelTableViewCell.h"


@interface FirstTitleDetailTravelTableViewCell ()
@property (nonatomic, assign) CGFloat height;
@end
@implementation FirstTitleDetailTravelTableViewCell

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)dealloc{
    [_descriptionLabel release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.descriptionLabel = [[UILabel alloc]init];
//        self.descriptionLabel.backgroundColor = [UIColor brownColor];
        [self.contentView addSubview:self.descriptionLabel];
        [_descriptionLabel release];
        
        self.heartView = [[UIView alloc]init];
        self.heartView.backgroundColor = [UIColor lightGrayColor];
        [self.contentView addSubview:self.heartView];
        [_heartView release];
        
        self.heartButon = [UIButton buttonWithType:UIButtonTypeCustom];
        [self.heartButon setBackgroundImage:[UIImage imageNamed:@"iconfont-xin-2"] forState:UIControlStateNormal];
        [self.contentView addSubview:self.heartButon];
    }
    return self;
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.descriptionLabel.frame = CGRectMake(10 * SWIDTH, 10 * SWIDTH, KWIDTH - 20 , self.height);
//    self.heartView.frame = CGRectMake(KWIDTH - 50, self.descriptionLabel.frame.size.height + self.descriptionLabel.frame.origin.y + 5, 40, 30);
//    self.heartButon.frame = CGRectMake(KWIDTH - 45, self.heartView.frame.origin.y + 5, 20 * SWIDTH, 20 * SWIDTH);
    self.heartButon.center = self.heartView.center;
}

- (void)setFirstLast:(FirstLastDetailModel *)firstLast{
    if (_firstLast != firstLast) {
        [_firstLast release];
        _firstLast = [firstLast retain];
    }
    self.descriptionLabel.text = firstLast.textDescription;
    self.descriptionLabel.numberOfLines = 0;
    self.descriptionLabel.font = [UIFont systemFontOfSize:14];
    self.height = [SuitableHeight suitableHeight:firstLast.textDescription andWidth:KWIDTH - 20 andFont:14];
}
@end
